<?php
/*
 * 手机客户端 秀场学院接口
 * 传入参数 
 * 2013-12-011
 */
include "inc/public_header.php";
 
$reJson = array();//构建返回值
 
$page			= $_REQUEST["page"]; 			//页数，第一页为0
$pagesize		= $_REQUEST["pagesize"];		//每页记录数
$hd_id			= $_REQUEST["hd_id"];			//活动主键

//学院logo根目录
$XUEYUAN_LOGO_BASE_PATH="http://adio.chinalaohu.com/app/pic/";
 
if(!isset($page)){
	$page = 0;
}
if(!isset($pagesize)){
	$pagesize = 20; 					//默认每页20条
}

$reJson["success"] = "1";

//学院总数
$sql = "select 
			count(distinct b.xuexiao_id) as ct
		from 
			new_weituo_zuopin a 
			left join new_weituo_person b on a.uid=b.uid 
			left join new_weituo_xuexiao c on b.xuexiao_id=c.id 
		where 
			a.dr='0' 
			and a.aflag='1' 
			and not b.xuexiao_id is null
			and c.id!='11'
		";
$db->query($sql);
$db->next_record();
$reJson["count"] = $db->f("ct"); //学院总数统计

//学院信息
$sql = "select 
			distinct b.xuexiao_id
			,c.aname
			,c.logo_name
		from 
			new_weituo_zuopin a 
			left join new_weituo_person b on a.uid=b.uid 
			left join new_weituo_xuexiao c on b.xuexiao_id=c.id 
		where 
			a.dr='0' 
			and a.aflag='1' 
			and not b.xuexiao_id is null 
			and c.id!='11'
		"; 
$sql = $sql."order by b.xuexiao_id desc limit ".($page * $pagesize).",".$pagesize;
$db->query($sql);
$xuexiaoArr = array();
while($db->next_record()){
	$xuexiaoArr[] = array(
		"imgurl"=>$XUEYUAN_LOGO_BASE_PATH.$db->f("logo_name")				//学院logo图片
		,"cname"=>$db->f("aname")											//学院名称
		,"cid"=>$db->f("xuexiao_id")										//学院id

	);
}			
//放入学校信息
$reJson["list"] = $xuexiaoArr;

echo json_encode($reJson);
?>
